<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue.directive</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
<h1>Computed Option 计算选项</h1>
<hr>
<div id="app">
{{canyi}}
    <p>温度{{wendu}}</p>
    <p><button @click="shenggao">升高温度</button><button @click="jiangdi">降低温度</button></p>
</div>
<script type="text/javascript">

    var app=new Vue({
        el:'#app',
        data:{
            wendu:14,
            suggestion:["T血","夹克长裙","绵衣羽绒服"],
            canyi:"fdfd",
        },
        methods:{
            shenggao:function () {
                this.wendu+=5;
            },
            jiangdi:function () {
                this.wendu-=5;
            }
        },
       watch:{
            wendu:function(newVal,oldVal){
                if(newVal>=26){
                    this.canyi=this.suggestion[0];
                }else if(newVal<26 && newVal >=0)
                {
                    this.canyi=this.suggestion[1];
                }else{
                    this.canyi=this.suggestion[2];
                }
            }
       }
    })
</script>
</body>
</html>
</html>